package com.ethan.modules.organization.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ethan.common.orm.Page;
import com.ethan.modules.organization.dao.DepartmentDao;
import com.ethan.modules.organization.model.Department;

@Component
@Service
@Transactional
public class DepartmentService {
	@Resource
	private DepartmentDao deptDao;
	
	public Page<Department> findPage(final Page<Department> page, final String hql){
		return deptDao.findPage(page, hql); 
	}
	
	public Department findUniqueBy(final String propertyName,
			final Object value) {
		return deptDao.findUniqueBy(propertyName, value);
	}
	
	public List<Department> find(String hql) {
		List<Department> list = new ArrayList<Department>();
		list = deptDao.find(hql);
		return list;
	}

	public void save(Department dept) {
		deptDao.save(dept);
	}
	
	public Department findID(Long id){
		return  deptDao.get(id);
	}

	public List<Department> findby(final String propertyName, final Object value) {
		List<Department> list = new ArrayList<Department>();
		list = deptDao.findBy(propertyName, value);
		return list;
	}
		
	/** 
	 * 用户真实删除
	 */
	public void deleteDept(Long id) {
		Department dept = deptDao.get(id);
		deptDao.delete(dept);
	}

	
}
